var init = require('init');
var configData = require('configData');
cc.Class({
    extends: cc.Component,

    properties: {
        updateBtn:cc.Node,
        updateContent:cc.Node,
        luckySpin:cc.Node,
        luckySpinContent:cc.Node,
    },

    // LIFE-CYCLE CALLBACKS:
    onLoad () {
        if(CC_JSB){
            cc.configData = configData;
            cc.sys.localStorage.setItem("money",cc.configData.money);
            cc.find('Canvas').emit('money');
            cc.sys.localStorage.setItem("diamond",cc.configData.diamond);
            cc.find('Canvas').emit('diamond');
        }else{
            cc.sdkbox.getDataAsync(['money','diamond','guestNum','material','lock'],function(data){
                console.log(data);
                if(!data.material){
                    cc.configData = configData;
                    cc.sdkbox.setDataAsync(cc.configData,function(){
                        console.log('存储成功');
                    });
                }else{
                    cc.configData = data;
                }
                cc.sys.localStorage.setItem("money",cc.configData.money);
                cc.find('Canvas').emit('money');
                cc.sys.localStorage.setItem("diamond",cc.configData.diamond);
                cc.find('Canvas').emit('diamond');
            });
        }
        this.btnEven();
        this.init();
        //cc.gameStart.getPrefab();
    },
    start(){

    },
    init(){
        cc.audioEngine.stopAll();
        cc.voicePlay.loader();
        cc.bgm.loader();
        cc.shareBg.loader();
        cc.gameList.loader();
        cc.voicePlay.isStart = true;
        this.scheduleOnce(function(){
            if(cc.voicePlay.volume === 1){
                cc.bgm.play();
            }
        },0.5)
    },
    btnEven(){
     this.updateBtn.on('click',function(){
         cc.voicePlay.playEffect('click');
         this.updateContent.active = true;
         this.updateContent.getComponent('update').init();
     },this);
        this.luckySpin.on('click',function(){
            cc.voicePlay.playEffect('click');
            this.luckySpinContent.active = true;
            this.luckySpinContent.getComponent('Luckyspin').init();
        },this)
    },
    startBtn(){
        cc.voicePlay.playEffect('click');
        cc.director.loadScene('cookingFever2');
    },
    update (dt) {

    },
});
